package cn.sumpu.app.guoguojie.domain;

import java.io.*;
import java.util.*;

public class DoingTagShow implements Serializable {

	private static final long serialVersionUID = 6395623805199615740L;
	

	private String identifier;
	private String parentIdentifier;
	private String name;
	private Integer deep;
	private String style;
	private Integer type;
	private String backTag;
	
	private String keywords;//标签的关键词
	
	private Date gmtCreated;
	private Date gmtModified;
	//自己的子类
	private List<DoingTagShow> tagList = new ArrayList<DoingTagShow>();
	//自己的父类
	private DoingTagShow doingTag;
	
	//所有前台标签
	public static List<DoingTagShow> doingTagShow = new ArrayList<DoingTagShow>();
	
	public String getBackTag() {
		return backTag;
	}
	public void setBackTag(String backTag) {
		this.backTag = backTag;
	}
	public String getIdentifier() {
		return identifier;
	}
	public void setIdentifier(String identifier) {
		this.identifier = identifier;
	}
	public String getParentIdentifier() {
		return parentIdentifier;
	}
	public void setParentIdentifier(String parentIdentifier) {
		this.parentIdentifier = parentIdentifier;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getDeep() {
		return deep;
	}
	public void setDeep(Integer deep) {
		this.deep = deep;
	}
	public String getStyle() {
		return style;
	}
	public void setStyle(String style) {
		this.style = style;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public Date getGmtCreated() {
		return gmtCreated;
	}
	public void setGmtCreated(Date gmtCreated) {
		this.gmtCreated = gmtCreated;
	}
	public Date getGmtModified() {
		return gmtModified;
	}
	public void setGmtModified(Date gmtModified) {
		this.gmtModified = gmtModified;
	}
	public List<DoingTagShow> getTagList() {
		return tagList;
	}
	public void setTagList(List<DoingTagShow> tagList) {
		this.tagList = tagList;
	}
	public DoingTagShow getDoingTag() {
		return doingTag;
	}
	public void setDoingTag(DoingTagShow doingTag) {
		this.doingTag = doingTag;
	}
	
	public String getKeywords() {
        return keywords;
    }
    public void setKeywords(String keywords) {
        this.keywords = keywords;
    }
    //根据父ID取得子标签集合(遍历树)
	public static List<DoingTagShow> getTagsByPid(String parentId){
		if(parentId.equals("0")){
			return doingTagShow;
		}
		for(DoingTagShow t : doingTagShow){
			if(t.getIdentifier().equals(parentId)){
				return t.getTagList();
			}
			List<DoingTagShow> list = getTagsByPid(t.getTagList(), parentId);
			if(list.size()>0){
				return list;
			}
		}
		return new ArrayList<DoingTagShow>();
	}
	public static List<DoingTagShow> getTagsByPid(List<DoingTagShow> l, String parentId){
		for(DoingTagShow t : l){
			if(t.getIdentifier().equals(parentId)){
				return t.getTagList();
			}
			List<DoingTagShow> list = getTagsByPid(t.getTagList(), parentId);
			if(list!=null && list.size()>0){
				return list;
			}
		}
		return new ArrayList<DoingTagShow>();
	}
	
}
